Repository navigation
Fix relative format showing now for any past time under a minute - #390
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are recorded for the fix restoring second-level relative output for past timestamps.
No open issues 🎉
What changed in this PR
Fixes #269 by restoring second-level relative output for past timestamps instead of incorrectly displaying “now” throughout the preceding minute.
Changes:
- Uses the absolute seconds value for the “now” threshold, treating past and future timestamps consistently.
- Updates the 50-seconds-ago test expectations for standard and narrow formatting.
| File | Description |
|---|---|
test/relative-time.js |
Expects “50 seconds ago” and “50s ago” in the existing regression cases. |
src/relative-time-element.ts |
Applies Math.abs(int) to the under-10-second threshold. |
Review effort: Max
liuliu-dev
approved these changes
Nov 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #269
#getRelativeFormatinsrc/relative-time-element.tsturns anything under 10 seconds into "now":For past dates
intis negative, so this is always true and every past time under a minute renders as "now". Future dates are fine, which is why the table tests expect "in 50 seconds" for 50 seconds ahead but "now" for 50 seconds ago.Before
#getRelativeFormatswitched to durations,timeAgoreturned "now" under 10 seconds and "N seconds ago" from 10 to 44 seconds, so this looks like a regression from that change. The fix comparesMath.abs(int).I updated the two "50 seconds in the past" table tests that encoded the old output. They fail before the change and pass after. I ran the full test suite (
web-test-runner, Chromium),tsc --noEmitand eslint.